function downloadFile(url) {
	var elemIF = document.createElement("iframe");
	elemIF.src = url;
	elemIF.style.display = "none";
	document.body.appendChild(elemIF);
}

function getAllSelectedValues(formid) { // 返回选中值
	var tform = document.forms[formid];
	var t = 0;
	var b = new Array();
	for ( var i = 0; i < tform.length; i++) {
		var e = tform.elements[i];
		if (e.type == "checkbox" && e.checked == true) {
			b[t] = e.value;
			t++;
		}
	}
	return b;
}

/** Show dialog that can be download as a excel file start */
function cv_export(MY_DOMAIN, UserID) {
	if (!window.pop) {
		var Temp_Sel_Param = {
			openType :2, // 居中定位
			filterParam : {}, // 滤镜层设置
			createIfr :false
		}
		window.pop = new ExtZzLayer(Temp_Sel_Param);
	}
	var em = getAllSelectedValues('queryemployeeform');
	if(em.length == 0){
		hiAlert('请至少选择一个需要导出的员工 ！', '注意');
		return;
	}
	var hiddenFields = "<div style='visibility:hidden;'>";
	for(var i=0; i< em.length; i++){
		hiddenFields += "<input type=\"hidden\" name=\"EmployeeID\" value='"+em[i]+"'>";
	}
	hiddenFields += "</div>";
	// var action_url =
	// MY_DOMAIN+"/download.do?action=excel&UserID="+UserID+"&rand="+Math.random();
	// The innerHtml value which should be come from server using ajax request
	var innerHtml = "<div class=\"window04\">"
			+ "<p class=\"window_title\">"
			+ "	<span class=\"window_close02 top_login_close\" id=\"window_close\" style=\"padding:1px;\"><img src=\""
			+ MY_DOMAIN
			+ "/images/dialog/icon_close.gif\" align=\"absmiddle\" /></span>"
			+ "</p>"
			+ "<form method=\"post\" action=\""
			+ MY_DOMAIN
			+ "/download.do?action=excelUser&rand="
			+ Math.random()
			+ "\" target=\"_blank\" onsubmit=\"return checkExportSet('0');\">"
			+ "<input type=\"hidden\" name=\"UserID\" value='"+UserID+"'>"
			+ hiddenFields
			+ "<div class=\"window_con04\">"
			+ "	<div style=\"text-align:left;margin:10px 15px;line-height:26px;\">"
			+ "		<div class=\"or\"><b>请选择导出格式：</b></div>"
			+ "		<div><input name=\"type\" type=\"radio\" id=\"type\" value=\"excel\" onclick=\"show_message(0, 0);\" />excel文件&nbsp;&nbsp;<input name=\"type\" type=\"radio\" id=\"type\" value=\"html\" onclick=\"show_message(1, 0);\" />Html文件</div>"
			+ "  		<div id=\"show_message\" style=\"display: none;\"></div>"
			+ "		<hr width=\"100%\" size=\"1\" style=\"color: rgb(224, 224, 224);\"/>"
			+ "		<div style=\"text-align:center;height:25px;margin-top:5px;\"><input type=\"image\" border=\"0\" src=\""
			+ MY_DOMAIN
			+ "/images/dialog/pay_button.gif\" style=\"cursor: pointer;\"/></div>"
			+ "	</div>" + "</div>" + "</form>" + "</div>";
	pop.setContent(innerHtml);
	pop.setCloseNode('window_close');
	pop.open();
	// $.get( action_url, function(result) {
	// pop.setContent( result );
	// pop.setCloseNode( 'window_close' );
	// pop.open();
	// } );
}

function checkExportSet(isEnglish) {
	pop.close();
	return true;
}

function show_message(exportType, language) {
	var show_message = '';
	if ('0' == exportType) {
		if ('0' == language) { // 中文的word导出
			show_message = '注： 支持excel2003及以上版本';
		} else if ('1' == language) { // 英文的word导出
			show_message = 'Note: Support Word 2003 and above';
		}
		$('#show_message').html(show_message);
	} else if (1 == exportType) {
		if ('0' == language) { // 中文的html导出
			show_message = '注： 支持IE,Firefox等浏览器';
		} else if ('1' == language) { // 英文的html导出
			show_message = 'Note: Support IE browser only';
		}
		$('#show_message').html(show_message);
	}
	$('#show_message').css( {
		'display' :'block',
		'color' :'#F67214'
	});
}
/** Show dialog that can be download as a excel file end* */
